<?php

/**
 * Wave Framework <http://www.waveframework.com>
 * View Controller
 *
 * Wave Framework comes with a View Controller and a translations system that is used to build 
 * a website on Wave Framework. This View Controller is entirely optional and can be removed 
 * from a system if you plan to implement your own View Controller or simply use Wave Framework 
 * for API, without a website.
 *
 * @package    Tools
 * @author     Kristo Vaher <kristo@waher.net>
 * @copyright  Copyright (c) 2012, Kristo Vaher
 * @license    GNU Lesser General Public License Version 3
 * @tutorial   /doc/pages/guide_view.htm
 * @since      1.0.0
 * @version    3.6.9
 */

class WWW_controller_business extends WWW_Factory {

	/**
	 * This method is called by Data Handler to render View contents based on values from 
	 * URL Controller.
	 *
	 * @param array $input input data sent to controller
	 * @input mixed input data from URL Controller output
	 * @return null
	 */
	  
	public function create_category($data)
	{	
		//echo "<pre>";print_r($data);exit;
		$reason=array();
		if($data['category_name']=='')
		{
			$reason['category_nameerror']="Category Name should contain some value";
			$status="fail";
		}
		if($status!="fail")
		{
		$model=$this->getModel('business');
		$result=$model->create_category($data);
		//print_r($result);exit;
		return $this->resultTrue('result',$result);	
		}else
		{
			return $this->resultTrue('result',$reason);
		}
	}
	public function edit_category($data)
	{
		$model=$this->getModel('business');
		$result=$model->edit_category($data);
		//print_r($result);exit;
		return $this->resultTrue('result',$result);
	}
	public function get_category($data)
	{	//print_r($data);exit;
		$model=$this->getModel('business');
		$result=$model->get_category($data);
		return $this->resultTrue('result',$result);
	}
	public function delete_category($data){		
		$model=$this->getModel('business');
		$deleted_info = $model->delete_category($data);
		return $this->resultTrue('Delete modules Info',$deleted_info);
	}
	public function all_category($data)
	{		//print_r($data);exit;
		$model=$this->getModel('business');
		$modules_info = $model->all_category($data);
		return $this->resultTrue('All modules',$modules_info);		
	}
	public function create_business($data)
	{	
		//echo "<pre>";print_r($data);exit;
		$reason=array();
		if($data['business_name']=='')
		{
			$reason['business_nameerror']="Business Name should contain some value";
			$status="fail";
		}
		if($data['businesscat_id']=='')
		{
			$reason['category_nameerror']="Category	should contain some value";
			$status="fail";
		}
		if($data['business_type']=='')
		{
			$reason['business_typeerror']="Business Type should contain some value";
			$status="fail";
		}
		if($data['start_date']=='')
		{
			$reason['start_dateerror']="start date should contain some value";
			$status="fail";
		}
		if($data['address']=='')
		{
			$reason['addresserror']="Address should contain some value";
			$status="fail";
		}
		if($status!="fail")
		{
		$model=$this->getModel('business');
		$result=$model->create_business($data);
		//print_r($result);exit;
		return $this->resultTrue('result',$result);	
		}else
		{
			return $this->resultTrue('result',$reason);
		}
	}
	public function get_businesscategory_list()
	{	
		$model = $this->getModel('business');
		$result = $model->get_businesscategory_list();
		return $this->resultTrue('result',$result);
	}
	public function edit_business($data)
	{	
		$model=$this->getModel('business');
		$result=$model->edit_business($data);
		
		return $this->resultTrue('result',$result);
	}
	
	public function get_business($data)
	{	
		$model=$this->getModel('business');
		$result=$model->get_business($data);
		
		return $this->resultTrue('result',$result);
	}
	public function delete_business($data)
	{		
		$model=$this->getModel('business');
		$deleted_info = $model->delete_business($data);
		return $this->resultTrue('Delete modules Info',$deleted_info);
	}
	
	public function all_businesses($data)
	{		//print_r($data);exit;
		$model=$this->getModel('business');
		$modules_info = $model->all_businesses($data);	
		return $this->resultTrue('All modules',$modules_info);		
	}
	
}

?>